package com.upic.serviceImpl;

import com.upic.po.OperatorLog;
import com.upic.repository.OperatorLogRepository;
import com.upic.service.OperatorLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author YeTian
 * @date 2018/2/7/007
 */
@Service("operatorLogService")
public class OperatorLogServiceImpl implements OperatorLogService {

    @Autowired
    private OperatorLogRepository operatorLogRepository;

    @Override
    public OperatorLog saveOperatorLog(OperatorLog operatorLog) {
        return operatorLogRepository.save(operatorLog);
    }

    @Override
    public String deleteOperatorLog(long operatorLogId) {
        operatorLogRepository.delete(operatorLogId);
        return "SUCCESS";
    }

    @Override
    public Page<OperatorLog> searchOperatorLog(Pageable pageable) {
        return operatorLogRepository.findAll(pageable);
    }

    @Override
    public List<OperatorLog> searchOperatorLog() {
        return operatorLogRepository.findAll();
    }

    @Override
    public OperatorLog findOne(long operatorLogId) {
        return operatorLogRepository.findOne(operatorLogId);
    }

    @Override
    public OperatorLog updateOperatorLog(OperatorLog operatorLog) {
        return operatorLogRepository.saveAndFlush(operatorLog);
    }
}
